<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head th:include="common/_header :: header">
</head>

<body>
<div class="lyear-layout-web">
    <div class="lyear-layout-container">
        <!--左侧导航-->
        <aside class="lyear-layout-sidebar" th:include="common/_aside :: aside">
        </aside>
        <!--End 左侧导航-->

        <!--头部信息-->
        <header class="lyear-layout-header" th:include="common/_top :: top">
        </header>
        <!--End 头部信息-->

        <!--页面主要内容-->
        <main class="lyear-layout-content">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-lg-12">
                        <div class="card">
                            <div class="card-toolbar clearfix">
                                <form class="pull-right search-bar" method="get" action="#!" role="form">
                                    <div class="input-group">
                                        <div class="input-group-btn">
                                            <input type="hidden" name="search_field" id="search-field" value="title">
                                            <button class="btn btn-default dropdown-toggle" id="search-btn" data-toggle="dropdown" type="button" aria-haspopup="true" aria-expanded="false">
                                                标题 <span class="caret"></span>
                                            </button>
                                            <ul class="dropdown-menu">
                                                <li><a tabindex="-1" href="javascript:void(0)" data-field="title">标题</a></li>
                                                <li><a tabindex="-1" href="javascript:void(0)" data-field="cat_name">栏目</a></li>
                                            </ul>
                                        </div>
                                        <input type="text" class="form-control" value="" name="keyword" placeholder="请输入名称">
                                    </div>
                                </form>
                                <div class="toolbar-btn-action">
                                    <a class="btn btn-primary m-r-5" href="#!"><i class="mdi mdi-plus"></i> 新增</a>
                                    <a class="btn btn-success m-r-5" href="#!"><i class="mdi mdi-check"></i> 启用</a>
                                    <a class="btn btn-warning m-r-5" href="#!"><i class="mdi mdi-block-helper"></i> 禁用</a>
                                    <a class="btn btn-danger" href="#!"><i class="mdi mdi-window-close"></i> 删除</a>
                                </div>
                            </div>
                            <div class="card-body">

                                <div class="table-responsive">
                                    <table class="table table-bordered">
                                        <thead>
                                        <tr>
                                            <th>
                                                <label class="lyear-checkbox checkbox-primary">
                                                    <input type="checkbox" id="check-all"><span></span>
                                                </label>
                                            </th>
                                            <th>编号</th>
                                            <th>头像</th>
                                            <th>昵称</th>
                                            <th>QQ</th>
                                            <th>微信</th>
                                            <th>状态</th>
                                            <th>操作</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <tr th:each="user:${data.records}">
                                            <td>
                                                <label class="lyear-checkbox checkbox-primary">
                                                    <input type="checkbox" name="ids[]" value="1"><span></span>
                                                </label>
                                            </td>
                                            <td th:text="${user.id}"></td>
                                            <td th:text="${user.avatar}"></td>
                                            <td th:text="${user.nickname}"></td>
                                            <td th:text="${user.qq}"></td>
                                            <td th:text="${user.wechat}"></td>
                                            <td>
                                                <span th:if="${user.status == 1}" style="color: #1D1F2F;">正常</span>
                                                <span th:if="${user.status == 2}" style="color: #7d5b4e;">禁用</span>
                                                <span th:if="${user.status == 3}" style="color: #0FB25F">删除</span>
                                            </td>
                                            <td>
                                                <div class="btn-group">
                                                    <a class="btn btn-xs btn-default" href="#!" title="编辑" data-toggle="tooltip"><i class="mdi mdi-pencil"></i></a>
                                                    <a class="btn btn-xs btn-default" href="#!" title="查看" data-toggle="tooltip"><i class="mdi mdi-eye"></i></a>
                                                    <a class="btn btn-xs btn-default" href="#!" title="删除" data-toggle="tooltip"><i class="mdi mdi-window-close"></i></a>
                                                </div>
                                            </td>
                                        </tr>
                                        </tbody>
                                    </table>
                                </div>

                                <ul class="pagination" th:each="i:${#numbers.sequence(1,data.pages)}">
                                    <li th:if="${i==1}" class="disabled"><span>第一页</span></li>
                                    <li th:if="${data.current == i}" th:onclick="page([[${i}]])" class="active"><span th:text="${i}"></span></li>
                                    <li th:if="${data.current != i}" th:onclick="page([[${i}]])"><span th:text="${i}"></span></li>
                                    <li th:if="${i==data.pages}"><a href="#!">最后一页</a></li>
                                </ul>
                            </div>
                        </div>
                    </div>

                </div>

            </div>

        </main>
        <!--End 页面主要内容-->
    </div>
</div>

<div th:replace="common/_js::js">

</div>

<script type="text/javascript">
    $(function () {
        $('.search-bar .dropdown-menu a').click(function () {
            let field = $(this).data('field') || '';
            $('#search-field').val(field);
            $('#search-btn').html($(this).text() + ' <span class="caret"></span>');
        });
    });
    function page(pageNum) {
        let param = "";
        param += "pageNum=" + pageNum;
        window.location.href = "openCity?" + param;
    }

</script>
</body>
</html>